﻿package  com.devilcat.ws{
	import com.devilcat.ws.Basicws;
	import com.worlize.websocket.*;
	import com.devilcat.dt.Pokemondt;
	import com.devilcat.dt.Gamedt;
	import flash.utils.clearInterval;
	import flash.utils.setInterval;
	import flash.display.MovieClip;
	
	public class PVPLoadPokemon extends Basicws{
		var upid:int;
		var itv:uint;
		var pkmob:MovieClip;
		public function PVPLoadPokemon(_upid:int,pmc:MovieClip) {
			super("iw-protocol");
			upid=_upid;
			pkmob=pmc;
		}
		override function handleWebSocketOpen(event:WebSocketEvent):void
		{
		}
		public function Update(){
			var pack:Object = new Object();
			pack.uid=uid;
			pack.action="pvploadpokemon";
			var myJson:String = JSONString(pack);
			websocket.sendUTF(myJson);			
		}
		override function handleWebSocketMessage(event:WebSocketEvent):void
		{
			if (event.message.type === WebSocketMessage.TYPE_UTF8)
			{	
				var getdata:Object = JSONObject(event.message.utf8Data)
				Gamedt.BattleUI.PVPAutoSwitchEnd(getdata);
				pkmob.LoadData(getdata);
			}
		}

	}
	
}
